/**
* Copyright 2009, Jethro Grassie, Creative Jar Technology Ltd (http://www.cjtech.co.uk)
*
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice.
**/

package com.adobe.cairngorm;

import java.lang.Throwable;
import java.util.Locale;

import javafx.util.StringLocalizer;

public class CairngormError extends Throwable
{
    public var errorCode;
    public var data;

    override function toString():String
    {
        Locale.setDefault(Locale.ENGLISH);
        var localizer = StringLocalizer 
        {
            key: errorCode.toString()
        }
        var message:String = localizer.localizedString;
        if(message.contains("\{0\}"))
            message = message.replace("\{0\}", data.toString());
        return "CairngormError: {errorCode} {message}.";
    }
}

